// defines used in shader
#define TWO_PI (3.14159265 * 2)

// application exposed variables
float4x4 gWorld : WORLD;
float4x4 gViewProjection : VIEWPROJECTION;

// time since application started
float gTime : TIME;

// vertex shader inputs (must match the vertex declaration in C++)
struct VS_INPUT
{
    float3 untransformed_pos	: POSITION0;
};

// vertex shader outputs
struct VS_OUTPUT
{
    float4 transformed_pos	: POSITION0;
};

// the vertex shader, run once for each vertex
VS_OUTPUT myVertexShader(VS_INPUT input)
{
	VS_OUTPUT output; // what we will output

   	// transforming the incoming vertex into world, then camera, then clip space.
	float4x4 worldViewProj = mul(gWorld, gViewProjection);
	output.transformed_pos = mul(float4(input.untransformed_pos, 1.0f), worldViewProj);

	// send data along to the pixel shader (will be interpolated)
	return output; 
}

// the pixel shader, each rasterized triangle's pixels will run through this 
float4 myPixelShader(VS_OUTPUT input) : COLOR
{
	return float4( .5f, .5f, .5f, 1.0f);
}

// Techniques are read in by the effect framework.
// They allow one to add variation to how a particular shader might be executed. 
technique myTechnique
{
	// Each pass in the technique corresponds to a single iteration over all 
	// verticies sent during a draw call and the subsequently created pixels. 
	// If we had a special effect that required us to draw our geometry and pixels more than once,
	// we could acheive this by adding more passes across our vertex and pixel data.
    pass FirstPass
    {
		// request what vertex and pixel shader are to be used, this can change for each pass.
        vertexShader = compile vs_2_0 myVertexShader();
        pixelShader  = compile ps_2_0 myPixelShader();
		// Setting a few of the many D3D renderstates via the effect framework
		//ShadeMode = GOURAUD; // smooth color interpolation across triangles
        //FillMode = SOLID; // no wireframes, no point drawing.
        CullMode = CCW; // cull any clockwise polygons.
    }
}